import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef, Optional, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { map, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { MainComponent } from '../main/main.component';
import { BuilderMainComponent } from '../builder/builder-main/builder-main.component';
import { DashboardType, ForminData } from '../dashboard/dashboard-model';

@Component({
  selector: 'app-builder-viewer',
  templateUrl: './builder-viewer.component.html',
  styleUrls: ['./builder-viewer.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BuilderViewerComponent implements OnInit {
  @ViewChild(BuilderMainComponent)
  builder: BuilderMainComponent;

  destroy$ = new Subject();

  builderData: ForminData;

  constructor(
    public activatedRoute: ActivatedRoute,
    public changeDetectorRef: ChangeDetectorRef,
    @Optional() public main: MainComponent,
    public router: Router,
  ) { }

  ngOnInit() {
    this.main.builderViewer = this;
  }
}
